package cn.tedu.boot35.controller;

import cn.tedu.boot35.entity.Emp;
import cn.tedu.boot35.mapper.EmpMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EmpController {
    @Autowired
    EmpMapper mapper;

    @RequestMapping("/insert")
    public String insert(Emp emp){
        System.out.println("emp = " + emp);
        mapper.insert(emp);
        return "添加完毕!";
    }

    @RequestMapping("/select")
    public String select(){
        List<Emp> list = mapper.select();

        for (Emp emp:list
             ) {
            System.out.println(emp.getName()+emp.getSal());
        }
        return "查询完毕!";
    }
    @RequestMapping("/update")
    public String update(Emp emp){
        mapper.update(emp);
        return "修改完毕!<a href='select'></a>";
    }

}
